package com.exam.Service;

import com.exam.Entity.SingleQuestion;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.exam.Mapper.SingleQuestionMapper;

import java.util.List;

@Service
public class SingleQuestionService {

    @Autowired
    private SingleQuestionMapper singleQuestionMapper;

    public List<SingleQuestion> findByIdAndType(Integer PaperId) {
        return singleQuestionMapper.findByIdAndType(PaperId);
    }


    public List<SingleQuestion> findAll(int page, int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<SingleQuestion> result = singleQuestionMapper.findAll();
        // 包装分页结果
        PageInfo<SingleQuestion> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }


    public SingleQuestion findOnlyQuestionId() {
        return singleQuestionMapper.findOnlyQuestionId();
    }


    public int add(SingleQuestion singleQuestion) {
        return singleQuestionMapper.add(singleQuestion);
    }

    public int deleteById(Integer id) {
        return singleQuestionMapper.deleteById(id);
    }

    public List<Integer> findBySubject(String subject, Integer pageNo) {
        return singleQuestionMapper.findBySubject(subject,pageNo);
    }
}
